<{extend name="public/base"}>
<{block name="foot_source"}>
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">
<{/block}>
<{block name="content"}>
    <!-- left column -->
    <div class="col-md-12">
        <!-- general form elements -->
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title"><{$title}></h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form role="form">
                <div class="box-body">
                    <div class="form-group">
                        <label for="exampleInputEmail1">邮箱</label>
                        <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">密码</label>
                        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
                    </div>
                    <div id="uploader" class="wu-example">
                        <!--用来存放文件信息-->
                        <div id="thelist" class="uploader-list"></div>
                        <div class="btns">
                            <input type="text" class="form-control" value="" id="cover" />
                            <img src="" id="cover_show" />
                            <div id="picker">选择文件</div>
                        </div>
                    </div>

                </div>
                <!-- /.box-body -->

                <div class="box-footer">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
        <!-- /.box -->
    </div>


<{/block}>
<{block name="foot_script"}>
<script type="text/javascript">
    var BASE_URL = '/static/webuploader';
    var uploader = WebUploader.create({
        // swf文件路径
        swf: BASE_URL + '/js/Uploader.swf',
        // 文件接收服务端。
        server: '/admin/api/upload',
        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#picker',
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false
    });

    // 当有文件被添加进队列的时候
    uploader.on( 'fileQueued', function( file ) {
        uploader.upload();
    });

    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    uploader.on( 'uploadSuccess', function( file,data ) {
        console.log( data._raw );
        console.log(data.ext);
        console.log(data.filename);
        console.log(data.name);
        $("#cover").val(data.url);
        $("#cover_show").attr('src',data.url);
    });
</script>
<{/block}>

